import React from 'react'
import {NavLink, Routes, Route, Navigate} from 'react-router-dom'
import About from './pages/About'
import Home from './pages/Home'

export default function App() {
  return (
    <>
      <h2>App组件</h2>
      {/* 路由导航链接 */}
      <NavLink to="/about">About</NavLink>
      &nbsp;
      <NavLink to="/home">Home</NavLink>
      <hr/>
      {/* 路由组件显示: 注册路由组件 */}
      <Routes>
        <Route path='/about' element={<About/>} />
        <Route path='/home' element={<Home/>} />
        {/* 当访问项目根路径, 自动跳转到home路由 */}
        <Route path='/' element={<Navigate to="/home"/>} />
      </Routes>
    </>
  )
}
